package controller;

public class Calculator {

	public String convertDecimalToBinary(int decimal) {
		return Integer.toBinaryString(decimal);
	}

	public int convertBinaryToDecimal(String binary) {

		int decimal = 0;
		int binaryValue = 1;

		for (int i = 0; i < binary.length(); i++) {
			decimal += Integer.parseInt(Character.toString(binary
					.charAt((binary.length() - 1) - i))) * binaryValue;
			binaryValue = binaryValue * 2;
		}

		return decimal;

	}

}
